package com.playwright.util.course;

import com.microsoft.playwright.*;

/**
 * @author liyanhao
 * @Date 2024-01-03 14:38
 */
public class 拦截网络请求 {
    public static void main(String[] args) throws InterruptedException {
        try (Playwright playwright = Playwright.create()) {

            BrowserType.LaunchOptions launchOptions = new BrowserType.LaunchOptions().setHeadless(false).setSlowMo(500);

            Browser browser = playwright.chromium().launch(launchOptions);
            BrowserContext context = browser.newContext();
            Page page = context.newPage();
            page.route("**", route -> {
                System.out.println(route.request().url());
                route.resume();
            });
            page.navigate("https://mms.pinduoduo.com/login/");
            Thread.sleep(100000l);
        }
    }
}
